<?php

namespace Wechat\Controller;

class HomeController extends CommonController {

    public function index() {
        $map["h.position"] = 1;
        $activityList = D("Home")->alias("h")
            ->join("left join __ACTIVITY__ a on a.activity_id = h.link")
            ->where($map)
            ->order("h.home_id desc")
            ->field("h.*, a.title_image, a.activity_id")
            ->select();

        $map["h.position"] = 2;
        $productList = D("Home")->alias("h")
            ->join("left join __PRODUCT_DESC__ pd on pd.desc_id = h.link")
            ->where($map)
            ->field("h.*, pd.home_image, pd.desc_id")
            ->select();

        $map["h.position"] = 3;
        $scienceList = D("Home")->alias("h")
            ->join("left join __SCIENCE__ c on c.science_id = h.link")
            ->where($map)
            ->field("h.*, c.home_image, c.science_id")
            ->select();

        $map["h.position"] = 4;
        $caseList1 = D("Home")->alias("h")
            ->join("left join __CASE__ c on c.case_id = h.link")
            ->where($map)
            ->field("h.*, c.title_image, c.case_id")
            ->select();
        $map["h.position"] = 5;
        $caseList2 = D("Home")->alias("h")
            ->join("left join __CASE__ c on c.case_id = h.link")
            ->where($map)
            ->field("h.*, c.title_image, c.case_id")
            ->select();
//        unset($caseList[0]);

        $map["h.position"] = 6;
        $caseIndex = D("Home")->alias("h")
//            ->join("left join __SCIENCE__ c on c.science_id = h.link")
            ->where($map)
//            ->field("h.*, c.title_image")
            ->select();


        $this->assign("productList", $productList);
        $this->assign("activityList", $activityList);
        $this->assign("scienceList", $scienceList);
        $this->assign("caseList1", $caseList1);
        $this->assign("caseList2", $caseList2);
        $this->assign("caseIndex", $caseIndex);
        $this->display("index");
    }
}